"""
一个经典的参数错误
"""


def add(a, b):
    a += b
    return a


def show_error():
    x = 1
    y = 1

    z = add(x, y)
    print(z)
    print(x, y)
    # 输出结果：
    """
    2
    1 1
    """

    x = [1, 2]
    y = [3, 4]
    z = add(x, y)
    print(z)
    print(x, y)
    # 输出结果：
    """
    [1, 2, 3, 4]
    [1, 2, 3, 4] [3, 4]
    """


class Company:
    def __init__(self, name, staffs=[]):
        self.name = name
        self.staffs = staffs

    def add(self, staff):
        self.staffs.append(staff)

    def remove(self, staff):
        self.staffs.remove(staff)


def use_company():
    c1 = Company("Google", ["Kevin", "葛小伦", "天使彦"])
    c1.add("天使冷")
    c1.remove("天使彦")
    print(c1.staffs)
    # 输出结果：
    """
    ['Kevin', '葛小伦', '天使冷']
    """

    c2 = Company("Amazon")
    c2.add("天使冷")
    print(c2.staffs)
    # 输出结果：
    """
    ['天使冷']
    """

    c3 = Company("Apple")
    c3.add("蔷薇")
    print(c3.staffs)
    print(c2.staffs is c3.staffs)
    # 输出结果（出现经典的问题,因为c2和c3都默认使用[]）：
    """
    True
    ['天使冷', '蔷薇']
    """


if __name__ == '__main__':
    show_error()
    use_company()
